package testFileRW;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;


/*new object
 * open file with a path
 * readLine() return a line
 * remember to close file
 * */
public class FileIn {
	String tmp = null;
	File file = null;
	BufferedReader reader = null;
	
	public void openFile(String str){
		try {
			reader = new BufferedReader(
					new FileReader(
							new File("G:\\test\\"+str)));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public String readLine() {
		String tmp = null;
		try {
			tmp = reader.readLine();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return tmp;
	}
	
	public void closeFile(){
		try {
			reader.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
